package com.ptswitch.material.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ptswitch.material.model.security.Permission;

public interface PermissionMapper {
    @Select("select * from permission where id=#{id}")
    Permission findById(@Param("id") long id);

    @Select("select * from permission where id=#{id}")
    Permission findByIdWithRoles(@Param("id") long id);

    @Select("select * from permission")
    List<Permission> findAll(int init, long first, long size);

    @Update("update permission(displayName,permissionName)"//
            + " values(p.displayName,p.permissionName)")
    void update(@Param("p") Permission permission);

    @Insert("insert into permission(displayName,permissionName)"//
            + " values(p.displayName,p.permissionName) returning id")
    long add(@Param("p") Permission permission);
}
